package bing.commons.sql;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;

public class PostgresFunctionTest {

	public static void main(String args[]) {

		getDataByFun();
	}

	public static void getDataByFun() {
		System.out.print(" this is a test");
		try {
			Class.forName("org.postgresql.Driver").newInstance();
			String url = "jdbc:postgresql://localhost:5432/testdb";
			Connection con = DriverManager.getConnection(url, "postgres",
					"ptserver");
			Statement st = con.createStatement();
			// String sql = " select * from student" ;
			String sql = "select * from  nextvals_pt_object_type_seq(5)";
			ResultSet rs = st.executeQuery(sql);
			while (rs.next()) {
				System.out.println(rs.getString(1));
				// System.out.println(rs.getString( 2 ));
			}
			rs.close();
			st.close();
			con.close();
			System.out.println();
		} catch (Exception ee) {
			System.out.println(ee.getMessage());
		}
		
	}
}
